import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/index',
    name: 'Index',
    component: () => import('../views/Index.vue'),
    children: [
      {
        path: '/index/home',
        name: 'Home',
        component: () => import('../views/Home.vue'),
      },
      {
        path: '/index/classfly',
        name: 'Classfly',
        component: () => import('../views/Classfly.vue'),
      },
      {
        path: '/index/jd',
        name: 'Jd',
        component: () => import('../views/Jd.vue'),
      },
      {
        path: '/index/shop',
        name: 'Shop',
        component: () => import('../views/Shop.vue'),
      },
      {
        path: '/index/mine',
        name: 'Mine',
        component: () => import('../views/Mine.vue')
      },
    ]
  },

  {
    path: '/detail',
    component: () => import('../views/Detail.vue')
  },
  {
    path: '/',
    redirect: '/index/home',  // 重定向:重新指向其它path,会改变网址
  }


  // {
  //   path: '/',
  //   name: 'home',
  //   component: () => import('../views')
  // },
  // {
  //   path: '/',
  //   name: 'home',
  //   component: () => import('../views')
  // },
  // {
  //   path: '/',
  //   name: 'home',
  //   component: () => import('../views')
  // },
  // {
  //   path: '/detail',
  //   name: 'detail',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../components/Detail.vue')
  // }
]

const router = new VueRouter({
  // 路由模式 hash模式和 history模式
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
